/**
 * 
 */
package de.rotkiv.common.properties.config;

import java.util.HashMap;

import de.rotkiv.common.properties.PropertiesHandling;
import de.rotkiv.common.util.Toolbox;

/**
 * @author Vik
 *
 */
public class PropertiesMapperConfig implements IF_PropertiesConfig {



	//	  _____          __               _  _             __      __     _
	//	 |  __ \        / _|             | || |            \ \    / /    | |
	//	 | |  | |  ___ | |_  __ _  _   _ | || |_   ______   \ \  / /__ _ | | _   _   ___  ___
	//	 | |  | | / _ \|  _|/ _` || | | || || __| |______|   \ \/ // _` || || | | | / _ \/ __|
	//	 | |__| ||  __/| | | (_| || |_| || || |_              \  /| (_| || || |_| ||  __/\__ \
	//	 |_____/  \___||_|  \__,_| \__,_||_| \__|              \/  \__,_||_| \__,_| \___||___/
	//
	private static final String PLAYLIST_EXTENSION_DEFAULT 						= ".pls";
	private static final String TRACKS_DIRECTORY_DEFAULT						= "Tracks A-Z";
	private static final String DEFAULT_BASENAME_DEFAULT						= "~ALL~";
	private static final String MP3_OUTPUT_ORDNERNAME_INTERPRET_DEFAULT			= "Interpret";
	private static final String MP3_OUTPUT_ORDNERNAME_GENRE_DEFAULT				= "Genre";
	private static final String MP3_OUTPUT_ORDNERNAME_ALBUM_DEFAULT				= "Album";
	private static final String MP3_OUTPUT_ORDNERNAME_TITLE_DEFAULT				= "Titel";
	private static final String MP3_OUTPUT_ORDNERNAME_FILESYSTEM_DEFAULT		= "Filesystem";
	private static final String MP3_OUTPUT_FILESYSTEM_FILENAME_BASE_DEFAULT		= "-Playlist";
	private static final String TEXT_SORTED_DEFAULT								= " (Sorted)";
	private static final String MP3_OUTPUT_ORDNERNAME_INTERPRET_SORTED_DEFAULT 	= MP3_OUTPUT_ORDNERNAME_INTERPRET + TEXT_SORTED;
	private static final String MP3_OUTPUT_ORDNERNAME_GENRE_SORTED_DEFAULT		= MP3_OUTPUT_ORDNERNAME_GENRE + TEXT_SORTED;
	private static final String MP3_OUTPUT_ORDNERNAME_ALBUM_SORTED_DEFAULT 		= MP3_OUTPUT_ORDNERNAME_ALBUM + TEXT_SORTED;
	private static final String MP3_OUTPUT_ORDNERNAME_TITLE_SORTED_DEFAULT 		= MP3_OUTPUT_ORDNERNAME_TITLE + TEXT_SORTED;
	private static final String DEFAULT_FILL_SIGN_INT_DEFAULT 					= "0";





	public static ConfigBean convert2Bean(HashMap<String, String> map) {
		String playlistExtension  					= PropertiesHandling.getValue(map, PLAYLIST_EXTENSION, 					PLAYLIST_EXTENSION_DEFAULT);
		String tracksDirectory 						= PropertiesHandling.getValue(map, TRACKS_DIRECTORY, 						TRACKS_DIRECTORY_DEFAULT);
		String basename  							= PropertiesHandling.getValue(map, DEFAULT_BASENAME, 						DEFAULT_BASENAME_DEFAULT);
		String mp3outputOrdnernameInterpret 		= PropertiesHandling.getValue(map, MP3_OUTPUT_ORDNERNAME_INTERPRET, 		MP3_OUTPUT_ORDNERNAME_INTERPRET_DEFAULT);
		String mp3outputOrdnernameGenre   			= PropertiesHandling.getValue(map, MP3_OUTPUT_ORDNERNAME_GENRE, 			MP3_OUTPUT_ORDNERNAME_GENRE_DEFAULT);
		String mp3outputOrdnernameAlbum   			= PropertiesHandling.getValue(map, MP3_OUTPUT_ORDNERNAME_ALBUM, 			MP3_OUTPUT_ORDNERNAME_ALBUM_DEFAULT);
		String mp3outputOrdnernameTitle        		= PropertiesHandling.getValue(map, MP3_OUTPUT_ORDNERNAME_TITLE, 			MP3_OUTPUT_ORDNERNAME_TITLE_DEFAULT);
		String mp3outputOrdnernameFilesystem     	= PropertiesHandling.getValue(map, MP3_OUTPUT_ORDNERNAME_FILESYSTEM, 		MP3_OUTPUT_ORDNERNAME_FILESYSTEM_DEFAULT);
		String mp3outputOrdnernameFilesystemBase 	= PropertiesHandling.getValue(map, MP3_OUTPUT_FILESYSTEM_FILENAME_BASE, 	MP3_OUTPUT_FILESYSTEM_FILENAME_BASE_DEFAULT);
		String textSorted     						= PropertiesHandling.getValue(map, TEXT_SORTED, 							TEXT_SORTED_DEFAULT);
		String mp3outputOrdnernameInterpretSorted   = PropertiesHandling.getValue(map, MP3_OUTPUT_ORDNERNAME_INTERPRET_SORTED, MP3_OUTPUT_ORDNERNAME_INTERPRET_SORTED_DEFAULT);
		String mp3outputOrdnernameGenreSorted     	= PropertiesHandling.getValue(map, MP3_OUTPUT_ORDNERNAME_GENRE_SORTED, 	MP3_OUTPUT_ORDNERNAME_GENRE_SORTED_DEFAULT);
		String mp3outputOrdnernameAlbumSorted     	= PropertiesHandling.getValue(map, MP3_OUTPUT_ORDNERNAME_ALBUM_SORTED, 	MP3_OUTPUT_ORDNERNAME_ALBUM_SORTED_DEFAULT);
		String mp3outputOrdnernameTitleSorted     	= PropertiesHandling.getValue(map, MP3_OUTPUT_ORDNERNAME_TITLE_SORTED, 	MP3_OUTPUT_ORDNERNAME_TITLE_SORTED_DEFAULT);
		String fillSign		     					= PropertiesHandling.getValue(map, DEFAULT_FILL_SIGN_INT,					DEFAULT_FILL_SIGN_INT_DEFAULT);

		//
		ConfigBean bean = new ConfigBean();
		//
		bean.setPlaylistExtension(playlistExtension);
		bean.setTracksDirectory(tracksDirectory);

		bean.setBasename(basename);
		bean.setMp3outputOrdnernameInterpret(mp3outputOrdnernameInterpret);
		bean.setMp3outputOrdnernameAlbum(mp3outputOrdnernameAlbum);
		bean.setMp3outputOrdnernameGenre(mp3outputOrdnernameGenre);
		bean.setMp3outputOrdnernameTitle(mp3outputOrdnernameTitle);
		bean.setMp3outputOrdnernameFilesystem(mp3outputOrdnernameFilesystem);
		bean.setMp3outputOrdnernameFilesystemBase(mp3outputOrdnernameFilesystemBase);
		bean.setTextSorted(textSorted);
		bean.setMp3outputOrdnernameInterpretSorted(mp3outputOrdnernameInterpretSorted);
		bean.setMp3outputOrdnernameAlbumSorted(mp3outputOrdnernameAlbumSorted);
		bean.setMp3outputOrdnernameGenreSorted(mp3outputOrdnernameGenreSorted);
		bean.setMp3outputOrdnernameTitleSorted(mp3outputOrdnernameTitleSorted);
		//
		//		int schleifenMax = StringUtil.getIntValue(1000);
		bean.setSchleifendurchgaengeMax(1000);
		//
		fillSign = Toolbox.fill(fillSign, '0', 1, false);
		bean.setFillSignInt( fillSign.charAt(0) );
		//
		return bean;
	}



	//
	//
	//	public static HashMap<String, String> convertFromProfileToHashMap(ProfileBean profile) {
	//		HashMap<String, String> map = new HashMap<String, String>();
	//
	//		String lastPathInput 			= profile.getLastPathInput();
	//		String lastPathOutput 			= profile.getLastPathOutput();
	//		int maxTracksPerPlaylist 		= profile.getMaxTracksPerPlaylist() ;
	//		String[] musicFileExtensionsArr = profile.getMusicFileExtensions() ;
	//		String pathInput 				= profile.getPathInput() ;
	//		String pathOutput 				= profile.getPathOutput() ;
	//		String pathOutputPfadersetzung 	= profile.getPathOutputPfadersetzung() ;
	//		String pfadersetzungDurch 		= profile.getPathOutputPfadersetzungDurch() ;
	//		String playlistExtension 		= profile.getPlaylistExtension() ;
	//		boolean relativerPfad   		= profile.isSelectedRelativerPfad() ;
	//
	//		String musicFileExtensions 		= Toolbox.getStringFromArray(musicFileExtensionsArr, DELIMITER);
	//
	//		map.put(PROFILE_PATH_INPUT, pathInput);
	//		map.put(PROFILE_PATH_OUTPUT, pathOutput);
	//		map.put(PROFILE_PLAYLIST_EXTENSION, playlistExtension);
	//		map.put(PROFILE_MUSIC_FILE_EXTENSIONS, musicFileExtensions);
	//		map.put(PROFILE_MAX_TRACKS_PER_PLAYLIST, String.valueOf(maxTracksPerPlaylist));
	//		map.put(PROFILE_PFADERSETZUNG, pathOutputPfadersetzung);
	//		map.put(PROFILE_PFADERSETZUNG_DURCH, pfadersetzungDurch);
	//		map.put(PROFILE_LAST_PATH_INPUT, lastPathInput);
	//		map.put(PROFILE_LAST_PATH_OUTPUT, lastPathOutput);
	//		map.put(PROFILE_RELATIVER_PFAD, String.valueOf(relativerPfad));
	//		//
	//		return map;
	//	}
}
